﻿using Microsoft.Extensions.DependencyInjection;

using PLCS.Application.Contracts;
using PLCS.Client.IService;
using PLCS.Client.IService.ConfigManager;
using PLCS.Client.IService.EquipmentManager;
using PLCS.Client.IService.LogManager;
using PLCS.Client.IService.OrderTask;
using PLCS.Client.IService.ProcessSolution;
using PLCS.Client.IService.UserAuthorization;
using PLCS.Client.Service.ConfigManager;
using PLCS.Client.Service.EquipmentManager;
using PLCS.Client.Service.LogManager;
using PLCS.Client.Service.OrderTask;
using PLCS.Client.Service.ProcessSolution;
using PLCS.Client.Service.UserAuthorization;

using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;

namespace PLCS.Client.Service;

[DependsOn(typeof(PLCSClientIServiceModule))]
public class PLCSClientServiceModule : AbpModule
{
    public const string RemoteServiceName = "Default";

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        AddAppClientServices(context);

        context.Services.AddHttpClientProxies(
            typeof(PLCSApplicationContractsModule).Assembly,
            RemoteServiceName
        );

        Configure<AbpVirtualFileSystemOptions>(options =>
        {
            options.FileSets.AddEmbedded<PLCSClientServiceModule>();
        });
    }

    private void AddAppClientServices(ServiceConfigurationContext context)
    {
        context.Services.AddScoped<IUserService, UserService>();
        context.Services.AddScoped<IOperationLogService, OperationLogService>();
        context.Services.AddScoped<IPLCReadDataService, PLCReadDataService>();
        context.Services.AddScoped<IPLCConfigService, PLCConfigService>();
        context.Services.AddScoped<IConfigService, ConfigService>();
        context.Services.AddScoped<IEquipmentService, EquipmentService>();
        context.Services.AddScoped<IStationService, StationService>();
        context.Services.AddScoped<ITrayService, TrayService>();
        context.Services.AddScoped<IInterfaceLogService, InterfaceLogService>();
        context.Services.AddScoped<IOrderService, OrderService>();
        context.Services.AddScoped<ITaskService, TaskService>();
        context.Services.AddScoped<IHisOrderService, HisOrderService>();
        context.Services.AddScoped<IHisTaskService, HisTaskService>();
        context.Services.AddScoped<IInstructionService, InstructionService>();
        context.Services.AddScoped<IHisInstructionService, HisInstructionService>();
        context.Services.AddScoped<IProcessService, ProcessService>();
        context.Services.AddScoped<ISolutionService, SolutionService>();
        context.Services.AddScoped<IUserService, UserService>();
        context.Services.AddScoped<IRoleService, RoleService>();
        context.Services.AddScoped<IMenuService, MenuService>();
        context.Services.AddScoped<IErrorLogService, ErrorLogService>();
        context.Services.AddScoped<IErrorLibraryService, ErrorLibraryService>();
    }
}